Repository navigation
feat: Send to agent and agent messaging - #379
Merged
Merged
Conversation
…ject agent_message_send takes the sender from the provider credential's thread and only the fields to, text and clientRequestId, so no argument can name a sender. A recipient outside the caller's project gets the same refusal as an address that does not exist. The message row and its queue entry commit in one transaction through the server dispatcher's own path. ServerTurnStarter shares that path's inner function and adds the message companion. The dispatch path reads the session again and queues the envelope only while the recipient's turn runs, so it never steers and never strands a message behind a turn that already ended. The hosted-agent actor is an agent kind for the engine's personSend rule and is stored as its own actor_kind. It never names a source thread and never counts as an outside agent's running turn. The contract widens a message's actor to either kind. The thread reducer still builds a requester only for an outside agent, and MessageProvenance only widens its prop type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent message stayed accepted forever. The tracker derives its status from the recipient thread: the queue entry state, then the turn that took the message. That turn is found by its marker, by the message's turn id, or as the first turn the thread started after the entry was delivered, ordered by event sequence. A completed turn whose reply still streams keeps the message consumed until the reply settles. A derived status only moves forward, so a promoted entry that reads pending keeps queued, and a final status is never recomputed. Held rows are left alone except the ones an uncertain delivery made. The tracker reconciles a thread on its delivery, session, message, interrupt and delete events, and every open message at start and after a lagged broadcast. It reads and writes message rows only and never dispatches a command. The runtime stops it in the quiesce sequence after the send requests follower. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s status agent_message_reply answers a message the caller received. The reply goes to that message's sender in the same conversation, names the original in its envelope, and returns at once, so no agent waits inside a tool call. A caller that did not receive the message gets the same refusal as for an id that does not exist, and a sender that is gone gets RecipientGone. agent_message_status reads the stored status for the message's sender only and never recomputes it. replyMessageId is the newest reply in acceptance order (rowid), never by timestamp. The test helper that moves a queue entry now waits for the harness's own queue service, which can promote or deliver an entry before the test does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cargo clippy --all-targets -D warnings refused the enclosing Ok and ? (clippy::needless_question_mark). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tool tests call the family's run function with a hand-built scope, so only agents_list was proven through the provider endpoint. This test issues a provider credential and calls agent_message_send and agent_message_status through it, and checks that the stored sender is the credential's thread. The rpc-wire fixtures are regenerated for the widened message actor of task 5.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orktree-agent-abee30e91a12fc93c
…orktree-agent-a8809204a00bd362d
A message another BiBCode agent sends has actor kind hosted-agent. The transcript labelled every actor as an outside MCP agent, so an agent's message read as "Agent · <title>" like an outside client. The chip now has a hosted form, "From agent · <sender title>", with a tooltip saying the person did not write it. The kind comes from the actor only, never from message text, so pasted envelope text cannot produce the chip, and a person's send still shows only its own label. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Agent messaging is off by default and a person turns it on in Settings, Agents, Agent integrations. The switch writes only agentMessaging.enabled, applies without asking because it is reversible, offers a reset while on, and is disabled with a reason on a server that does not report the capability. It does not depend on the MCP server switch, since it governs BiBCode's own agents. It keeps its own save error so the message names this setting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ssaging switch Codex review of the settings switch: it stays usable while the server reconnects (the config snapshot is retained), and its explanation is not referenced from the control. These tests fail before the fix. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ence its description The retained config snapshot let the switch stay usable while the server reconnected; it now disables with a reconnecting reason. The explanation is given an id and referenced from the switch, with the reason when disabled. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Four tests that fail on the phase 5 code. A person can steer a queued agent message into the recipient's running turn (K1). An assistant item that names the turn before its running event leaves the message delivered, and a later unrelated turn that fails then fails it (K2), and a message whose turn link is gone is given that later turn. A reply reports nothing to the outcome sink. The outcome sink is now usable in tests, so its dead code expectation applies to the non-test build only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
K1. The steer command checked only that the entry was the queue head, so a person could steer a queued agent message into the running turn, and the steer path then sent it without the agent provenance. The spec says an agent message never steers, so the steer command now refuses an entry whose stored row is an agent message and says why; the entry stays queued and no steer event is written. K2. When a provider item named the turn before its running event, the projector met an existing turn and deleted the message's marker, so the link to the message was lost. The tracker then fell back to the first running event after the delivery was recorded, which missed the turn when it ran before that record and took an unrelated later one. The projector now keeps the marker's message on the existing running turn, as it already does when it binds a marker, and the tracker drops the event-order fallback and reads the turn already recorded on the message first, so a status follows only the message's own turn. A reply now reports its outcome to the outcome sink under agent_message_reply, as a send does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… off An agent message must never reach a recipient that runs with more access than its sender (R6), and a delivery claimed after messaging was turned off must not go out (R5). Send and reply refuse a recipient whose runtime mode ranks above the sender's with AgentMessagingModeCeilingError and store the sender's mode on the message. agents_list marks such a recipient canReceive false. The claim of a queue entry asks a gate installed on the shared repositories, inside the claim's own database call. It holds an agent's message while the setting is off or while the recipient's current mode ranks above the stored sender mode, and never claims a message already held for either reason or already final. A person's request always proceeds. The tracker holds a waiting message when its recipient's mode rises, and withdraws the queue entry of every message that is final or held for the setting or the ceiling, a definitely failed delivery included. Each hold writes the status first and the withdrawal reads the stored state, so a restart between the two still withdraws the entry and a person's message queued behind it is delivered. A hold decided at the claim writes no event, so the claim wakes the tracker. The steer command is reformatted by cargo fmt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent message must not act with a person's authority (R9). Three of these tests pass already because the promotion gate refuses a queued turn while an approval or question is open. The fourth fails: a ready session that still has an open approval, as after a restart, starts the message at once (its queue entry is pending, not queued). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
admission_for looked only at the session, so a ready session that still had an open approval or question (as after a restart recovers its asks) started the message at once, ahead of the person's answer. It now queues whenever the recipient has an open approval or question, and a queued admission forces the queue, so the promotion gate admits the message only after the person answered and no turn runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A provider tool call can time out after the message was stored, and the agent retries with the same clientRequestId (R12). The retry, a concurrent duplicate and a reply retry now fail with the store error, and the same id with other arguments is not reported as a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stId The provider tool path had no retry machinery, so a retry after a timeout hit the unique index and returned a store error (R12). Send and reply now look up the sender's message stored under the id first. The same recipient, text and inReplyTo return the stored receipt with its status as stored now and store nothing; anything else is AgentMessagingConflictError. When two calls race, the unique index decides: the losing call's whole command rolls back and it answers from the winner's row. The enabled check still runs first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… turn A first item that arrives settled before the running event must bind the message to that turn too (K2). It passes: a settled item with no streamed delta creates no turn row, so the running event binds the marker as usual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven tests fail on the current code, one per path that still lets an agent message past a safeguard or loses its status. N1. A context-limit recovery resends the message under a new command and message id with no agent message link, so the claim gate lets the copy through while messaging is off, and the tracker fails the message on the recovered turn. N2. A person's Send now promotes a queued agent message while its recipient has an open approval or question, and the claim hands it to the provider. N3. An early item that settles before the turn's running event loses the message's link to its turn. N4. A person can retry a failed agent delivery before the tracker has withdrawn it. N5. A retry with the same clientRequestId is refused once the recipient is archived or deleted, instead of replaying the stored receipt. Four guard tests pass already and keep passing: a person's Send now and retry are unchanged, an older turn never takes the marker, and a recovery without a copy fails the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A terminal agent needs an identity for agent messaging that no sibling terminal, plain shell or later process of the same terminal can use. TerminalCredentials issues 32 random bytes per AI Terminal launch into BIBCODE_AGENT_AUTH and BIBCODE_AGENT_ENDPOINT, stores only the hash, and verifies a token only while the terminal still runs the generation it was issued to. The launch hook now receives the terminal id, generation and whether the launch is an AI Terminal. The revoker removes an ended generation's tokens on Exited and Closed and sweeps only older generations on Restarted, because the hook issues the new token before the new session is published, so a terminal-wide revocation would remove it. The runtime holds the store and stops the revoker in quiesce; binding to the agent call route is left to the route's task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
N1. A context-limit recovery admitted its copy under a new command and message id, and nothing linked the agent message to it, so the claim gate, the envelope treatment and the tracker took the copy for a person's message. The copy's transaction now relinks the message to the copy (status accepted, recorded turn cleared) and admits no copy when the message can no longer be relinked. The tracker leaves a message alone while its recovery is unsettled and re-derives it on thread.compacted, so a recovery without a copy still fails it. N2. Manual promotion skipped the open approval and question check, and the claim gate never made it. The claim gate now waits while an agent message's recipient has an open ask, which covers every way an entry becomes pending, and a person's Send now of an agent message is refused with that reason. A person's own message keeps today's Send now. N3. The projector moved the marker to an early-reported turn only while that turn was running, so a turn that an early item had already settled lost the link. The transfer now ignores the turn's state and requires the turn to be first seen after the marker, so an older turn never takes it. N4. A person's retry of a failed entry did not check what the entry carried, so it could send a failed agent message before the tracker withdrew it. The resolution transaction now refuses that retry and says why; an uncertain delivery stays the person's call. N5. The stored-receipt replay ran after live routing, so a retry reached UnknownRecipient or RecipientGone once the recipient was archived or deleted. Send and reply now replay after the enabled and argument checks and before routing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut text A person needs to see each accepted, refused, delivered and failed agent message in Agent activity. agent_message_sink turns every outcome into one mcp_activity row of ids, the two thread titles and a state name, written by one task in arrival order so a send never waits on the database. The rows are kept out of changes_since and the webhooks, which rebuild every row as an outside agent call. The settings list says "to <title> · <state>". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The tracker gets the setting's watch and AgentMessaging gets requeue as interfaces only (requeue answers false), so the tests compile and show what is missing. Seven messaging_off tests fail: turning the setting off leaves a queued agent message in the queue, and nothing puts a held message back. The three ordering tests pass already, because the queue is read in receipt order; they pin that an agent message keeps its place among a person's messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them
The tracker now follows agentMessaging.enabled. While it is off, every
reconcile holds each agent message whose entry still waits (queued or
pending) with messaging_off and withdraws the entry, so a person's
message behind it is delivered; an entry already being sent completes,
as the accepted limit says. The startup reconcile does the same, so a
server that boots with messaging off holds what was left open.
While it is on, every reconcile releases the held messages whose cause
ended: one held for messaging_off or for the mode ceiling is checked
again (recipient alive, ceiling) and requeued, or fails with
recipient_gone, or stays held for recipient_mode_above_sender. Requeue
withdraws the old entry first, then admits one fresh turn start under
agent-message:{id}:{n} with a new thread message id and the
hosted-agent actor, and relinks the message in the same transaction
from held on the old entry. A second release or a stale one after a
restart finds the message moved and rolls back, so a message never has
two live entries and FIFO stays the receipt order.
withdraw_from_queue now counts an entry that is already dismissed as
out of the queue, which a release after an earlier withdrawal needs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The terminal pointer may type only into a CLI that waits for input, and done alone does not say that: a fresh session start, a session end and a failed turn also read done. Each observer now marks its current observation ready right after reporting a Claude Stop or idle_prompt, a Codex idle thread or completed turn, or an OpenCode idle session. Every new report clears the mark, so a working, blocked or waiting agent is never ready. TerminalAgentStatus carries the mark as readyForPrompt. A fresh, unavailable or exited agent reads false. The metadata mirror compares the mark, so marking an unchanged observation publishes a new summary. The contracts field is optional, absent meaning not ready, so existing client literals keep compiling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Six of the seven tests fail: every send and reply is hop 1, so a reply never counts one more than the message it answers and the ninth hop of a ping-pong is accepted. The first message in a turn a person started is hop 1 already and keeps passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A send or reply now takes its hop from the agent message that started the sender's active turn, found by the turn the message recorded or by the turn's marker, so either link alone is enough. A turn a person started has no such message, so the next send is hop 1 again; time never resets a chain. The ninth hop is refused with AgentMessagingHopLimitError, which names the limit, after the replay and routing checks and before anything is stored, so a retried hop-8 message still replays its receipt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…er spec The real-provider run now reads the terminal's screen after a person's request, keeps a longer preview text, sends an agent message containing a dollar sign to a Codex chat, and retries the first import after a launch timeout. The runbook records what the Codex chat shows for that message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ed re-run (task 11.3) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e8cf95bad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The conversation accessors use it on every platform; it was gated to Unix for the lossy-attach repaint only, which broke the Windows test target build. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The live PreToolUse guard proof (live_user_pre_tool_use_guard_still_blocks_with_the_bibcode_overlay, run with BIBCODE_CLAUDE_MERGE_PROOF on the 2.1.325 build on 2026-11-15) passed. The user's guard blocked the command, and BiBCode's UserPromptSubmit, PreToolUse, Stop and SessionEnd hooks arrived. The hook input schemas that build ships for every event BiBCode registers, the shared session_id and transcript_path fields, and the idle_prompt notification call site match the 2.1.323 build apart from minified names. The above-ceiling test example moves to 2.1.326. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… address The check compared owning thread ids, so a chat agent and an AI Terminal of one thread (or two terminals of one thread) could not take over from each other although they are different agents. The web list already excludes only the exact source agent, so it offered targets that always failed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The row and the answer notice dropped the terminal id of the request target, so Open only reached the owning thread. They now pass it on and the chat reveals the terminal tab (the Agents page helper moved to the center panel store). A closed terminal opens its thread and says so in a toast. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rvation A test added on this branch calls it on every platform; it was gated to Unix tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…the terminal Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ification Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude Code sets CLAUDE_CODE_CHILD_SESSION for its own child processes. A BiBCode started from inside a Claude Code session passed it on to every terminal, and an interactive Claude Code that inherits it saves no transcript. Send to agent then attached the recent output instead of the Claude terminal's conversation. A packaged run with only this variable added to a clean environment reproduced the fallback. The terminal environment drops it the way it drops multiplexer variables, by exact name and only when inherited. ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, CLAUDE_CONFIG_DIR, CLAUDECODE and CLAUDE_CODE_SKIP_PROMPT_HISTORY still pass through. The Claude chat provider runs Claude Code non-interactively, where the marker does not turn the transcript off, so its spawn is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e 380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
Desktop: intermittent hang at "Project data is still loading", client never opens its WebSocket
#381
Closed
mubeda
added a commit
that referenced
this pull request
Nov 19, 2026
Raises the Claude Terminal hook ceiling to Claude Code 2.1.328 after the live PreToolUse guard proof passed on that build, sets every version source to 0.17.0 and writes the curated changelog entry for PRs #370, #373, #379 and #387. Verified locally: cargo check --workspace --all-targets --locked, the hook ceiling tests, cargo fmt --all --check, vp check, vp run typecheck, vp run release:smoke and the Markdown link check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Two connected features, built from the plan in
docs/plans/2026-11-13-agent-messaging/(47 tasks, 46 closed;progress.mdholds the evidence per task).Send to agent (a person sends work from one agent to another)
sendRequests.*RPCs; a request keeps its state across restarts.Agent messaging (agents message each other, off by default)
agents_list,agent_message_send,agent_message_reply,agent_message_status,agent_message_cancel, and thebibcode agentcommand for an agent inside an AI Terminal (routePOST /api/agent/call, one credential per terminal generation).Fixes found on the way
wait_for_threadno longer settles while the reply still streams.Living documentation, the testing runbook, a packaged E2E spec and the changelog are updated in the same change.
main(v0.16.0) is merged in.Why
A person working with several agents had to copy text between them by hand, and agents had no way to ask each other. The design keeps a person's request and an agent's message apart (a person's request is exempt from the agent limits, an agent can never forge one), and it never types message text into a terminal.
Validation
On the final commit:
cargo test -p bibcode-server -j 2 --no-fail-fast: 99 test targets, 7,930 passed, 0 failed.cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --all --check: clean.vp run typecheck,vp run check:contracts,vp check, markdown links: pass.send-to-agent.e2e.ts6 passing; an OpenCode AI Terminal verified end to end; 0 Profiler findings, 0 crashes.Known Gaps
bibcodeshim, keyboard-only Dismiss in the terminal popover.ci:fulllabel and a later push, or a manual workflow run.UI Changes
New UI (the Send to agent control, preview, request rows, answer notice, the terminal's Send requests popover, the agent messaging setting). No screenshots or video are attached.
Checklist
🤖 Generated with Claude Code